home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-21 | 6.6 KB | 262 lines | [TEXT/QED1] |
- ONLY MAC
- ALSO DEVELOPMENT
- ALSO FORTH DEFINITIONS
- ALSO ASSEMBLER
-
- VARIABLE rel1 \ holds addr of offset for JSR d(PC)
-
- ( The following code is a inline patch to Mach2 2.14 Segment 17
- that allows the Editor to properly handle activate
- events. There were some problems in System 7.
- This code is a modification of the original routine, and cannot be
- larger than the original routine. )
-
- CODE edit.activate.event \ $002D973C - the original address
- LINK A2,#$-18
- LEA $-3A8(A5),A0 \ Ref: EVENT-RECORD
- MOVEA.L 2(A0),A0 \ get window pointer
- MOVE.L A0,$-4(A2) \ -> windowpointer
- EXG D4,A7
- MOVE.L A0,-(A7)
- _SetPort \ Trap #$A873
- EXG D4,A7
- LEA $-3A8(A5),A0 \ Ref: EVENT-RECORD
- MOVE.W $E(A0),D0 \ event.modifiers
- MOVEQ.L #$1,D1 \ 1 if window being activated
- AND.W D1,D0
- TST.W D0 \ IF
- BEQ.S @a \ +$96 $2D980E
-
- \ the edit window is being activated
- MOVEQ.L #$-1,D0 \ $-1
- MOVE.L D0,-(A6)
- JSR $1052(A5) \ @TEPtr
- MOVE.L (A6)+,A0
- MOVE.L (A6)+,D0
- MOVE.W D0,$62(A0)
-
- MOVE.L $-4(A2),A0
- MOVEQ.L #$0,D0 \ $0
- EXG D4,A7
- MOVE.L $9E(A0),-(A7)
- MOVE.W D0,-(A7)
- _HiliteControl \ Trap #$A95D
-
- MOVE.L $-4(A2),A0
- MOVE.L $A2(A0),-(A7)
- MOVE.W #$FF,-(A7)
- _HiliteControl \ Trap #$A95D
-
- CLR.L -(A7) \ clear space for the Task Pointer
- MOVE.L $-4(A2),-(A7) \ get the window pointer
- _GetWRefCon \ Trap #$A917
- MOVE.L (A7)+,A0 \ task pointer -> A0
- EXG D4,A7
-
- MOVE.L $-4(A2),$48(A0) \ TaskWindowpointer
-
- MOVEQ.L #$4A,D0 \ $4A
- MOVE.L D0,-(A6)
- JSR $1062(A5) \ InterfaceVector
- BRA @b \ +$122 $2D992C
-
- \ deactivate event
- @a \ $002D980E
- MOVE.L $-4(A2),-(A6) \ get windowpointer
- \ 002D9812
- JSR $-3A18(PC) \ $2D5DFC - do some processing
- [ HERE 2- rel1 ! ] \ save the routine offset - fill in later
- EXG D4,A7
- _InitCursor \ Trap #$A850
- EXG D4,A7
- MOVEQ.L #$0,D0 \ $0
- MOVE.L D0,-(A6)
- JSR $1052(A5) \ @TEPtr
- MOVE.L (A6)+,A0
- MOVE.L (A6)+,D0
- MOVE.W D0,$62(A0)
-
- MOVE.L $-4(A2),A0
- EXG D4,A7
- MOVE.L $9E(A0),-(A7) \ vertical scroll bar
- MOVE.W #$FF,-(A7)
- _HiliteControl \ Trap #$A95D
-
- MOVE.L $-4(A2),A0
- MOVE.L $A2(A0),-(A7) \ horiz scroll bar
- MOVE.W #$FF,-(A7)
- _HiliteControl \ Trap #$A95D
- EXG D4,A7
-
- LEA $48(A4),A0 \ Ref: TaskWindowPointer
- MOVE.L A0,-(A6)
- JSR $C62(A5) \ OPERATOR
- JSR $ACA(A5) \ TASK->
- MOVEA.L (A6)+,A0 \ @
- MOVE.L (A0),-(A6)
-
- \ now get the window scheduled for an activate event
- \ this is the new and modified part
- @get.activate
- EXG.L D4,A7
- CLR.W -(A7) \ reserve function result
- MOVE.W #$100,-(A7) \ only activate events in mask
- LEA $-18(A2),A0 \ temporary Event record
- MOVE.L A0,-(A7) \ push on stack
- _EventAvail
- MOVE.W (A7)+,D0 \ get the result
- EXG.L D4,A7
- TST.W D0 \ if there are no activate events
- \ then it is probably a Desk accessory
- BEQ.S @enable.edit
-
- \ there is an activate event in the Event queue, see if it is
- \ the Operator window
- MOVE.W $-18+$E(A2),D0 \ get modifiers
- BTST #0,D0 \ is it another deactivate
- BEQ.S @get.activate \ go back for another event
-
- \ it is an activate event
- MOVE.L $-16(A2),D1 \ get the window pointer
- MOVE.L (A6)+,D0 \ get the OPerator windowptr
- CMP.L D0,D1 \ are they equal
- BNE.S @non.Operator
-
- \ the window to be activated is the OPERATOR
- MOVEQ.L #$4B,D0 \ $4B routine selector
- MOVE.L D0,-(A6)
- JSR $1062(A5) \ InterfaceVector
- BRA.S @b \ +$7C $2D992C - exit
-
- \ it is not the Operator Window
- @non.Operator
- MOVE.L D1,A0 \ put the Windowpointer in A0
- MOVE.W $6C(A0),D0 \ get the windowKind
- TST.W D0 \ IF
- BGE.S @b \ +$5E $2D992C - branch if an application window
-
- \ the window to be activated is a System window
- @enable.Edit
- EXG D4,A7
- SUBQ.L #4,A7
- MOVE.W #$854,-(A7) \ EDIT menu
- _GetMHandle \ Trap #$A949
- MOVE.L (A7)+,D0 \ put menuhandle in D0
- EXG D4,A7
- MOVE.L D0,$-8(A2) \ store the menuhandle
- TST.L D0 \ IF the menu handle is NIL
- BEQ.S @b \ +$38 $2D992C don't try to enable it
-
- \ we have a valid EditMenu handle
- EXG D4,A7
- MOVE.L D0,-(A7) \ Edit menu handle
- CLR.W -(A7) \ enable entire menu
- _EnableItem \ Trap #$A939
- MOVE.L $-8(A2),-(A7) \ menu handle
- MOVE.W #1,-(A7) \ enable the Undo menu selection
- _EnableItem \ Trap #$A939
- EXG D4,A7
-
- @b \ $002D992C
- EXG D4,A7
- MOVE.L $-4(A2),-(A7)
- _DrawGrowIcon \ Trap #$A904
- EXG D4,A7
- UNLK A2
- RTS
- END-CODE
-
- HEADER end.of.new
-
- ( The following code is a inline patch to Mach2 2.14 Segment 17
- that allows the Editor to properly handle a text file being
- opened at startup. There were some problems in System 7.
- This code is a modification of the original routine, and cannot be
- larger than the original routine. )
-
- CODE C17Startup
- \ D2(A4) positive
- \ starting addr is 002DC1CA
- \ _Debugger
- MOVE.L MACH2.flags,D0 \ 1CA
- BTST #1,D0 \ Apple Events exist 1CE
- BEQ.S @old.open \ 1D0
-
- \ we get here when Apple Events exist, so the file information
- \ is a AppParms record in the SFReply buffer
- \
- LEA $-4DA(A5),A0 \ FSSSpec.VRefNum 1D2
- BRA.S @new.open \ 1D6
-
- @old.open
- MOVE.L $AEC,A0 \ AppParmsHandle in A0 1D8
- MOVEA.L (A0),A0 \ pointer in A0 1DE
- @new.open
- ADDQ.L #$4,A0 \ 4+ - bypass count and message 1E0
- MOVE.W (A0),D0 \ get file volume refnum 1E2
- EXT.L D0 \ 1E4
- MOVE.L D0,-(A6) \ file ioVRefNum 1E6
- ADDQ.L #6,A0 \ offset to filename 1E8
- MOVE.L A0,-(A6) \ ( -- ioVRefNum ioNamePtr ) 1EA
- MOVEQ.L #$2F,D0 \ $2F 1EC
- MOVE.L D0,-(A6) \ 1EE
- NOP \ 1F0
- NOP \ 1F2
- END-CODE
- HEADER C17Startup.end
- \ final address is $2DC1F4
-
- : modify.CODE17
- { | code.handle routine.ptr -- }
-
- ['] end.of.new ['] edit.activate.event -
- $002D9940 $002D973C -
- >
- IF
- CR
- ." New code patch is larger than old. Aborting …"
- ABORT
- THEN
-
- ASCII CODE 17 CALL GetResource -> code.handle
- code.handle 0= NOT
- IF
- code.handle CALL GetResAttrs
- $E7 AND \ clear the locked, protected bits
- code.handle SWAP CALL SetResAttrs
- code.handle CALL HLock DROP
- code.handle @ CALL StripAddress
- $002D973C $002D4C9A - + -> routine.ptr
-
- $-3A18 \ old offset from IP to routine
- $002D9814 $002D973C - \ old offset from start to IP
- + \ offset from start to routine
- rel1 @ ['] edit.activate.event - \ new offset from start to IP
- - \ offset from new IP to routine
- rel1 @ W!
-
- routine.ptr
- $002D9940 $002D973C -
- 0
- FILL
-
- ['] edit.activate.event
- routine.ptr
- ['] end.of.new ['] edit.activate.event -
- CMOVE
-
- ( now copy the C17Startup code into place )
- ['] C17Startup
- code.handle @ [ $2DC1CA $2D4C9A - ] LITERAL +
- [ ' C17Startup.end ' C17Startup - ] LITERAL
- CMOVE
-
- code.handle CALL HUnlock DROP
- code.handle CALL ChangedResource
- code.handle CALL WriteResource
- BYE
- ELSE
- CR
- ." CODE 17 could not be loaded."
- THEN
- ;